package com.example.serverSide.controller;

import com.example.serverSide.commom.ResultData;
import com.example.serverSide.pojo.Orders;
import com.example.serverSide.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/order")
public class OrdersController {
    @Autowired
    OrdersService ordersService;
    @PostMapping("/addOrder")
    public ResultData addOrder(@RequestBody Orders orders){
        System.out.println(orders);
        ordersService.addOrder(orders);
        return ResultData.success("Order added successfully");
    }
    @GetMapping("/getOrders")
    public ResultData getOrders(){
        List<Orders> list = ordersService.getOrders();
        return ResultData.success(list);
    }
    @GetMapping("/getOrder/{id}")
    public ResultData getOrders(@PathVariable("id") Long id){
        Orders order = ordersService.getOrder(id);
        return ResultData.success(order);
    }
    @PostMapping("/deleteOrder/{id}")
    public ResultData deleteOrder(@PathVariable("id") String id){
        System.out.println(id);
        String s = ordersService.deleteOrder(id);
        return ResultData.success("shit");
    }
    @PostMapping("/transferOrder")
    public ResultData transferOrder(@RequestBody Orders orders){
        ordersService.transferOrder(orders);
        return ResultData.success("shit");
    }
    @PostMapping("/updateOrderMaterial")
    public ResultData updateOrderMaterial(@RequestBody Orders orders){
        ordersService.updateOrderMaterial(orders);
        System.out.println(orders);
        return ResultData.success("shit");
    }
    @PostMapping("/denyOrder")
    public ResultData denyOrder(@RequestBody Orders orders){
        ordersService.denyOrder(orders);
        return  ResultData.success("shit");
    }
    @PostMapping("/passOrder")
    public ResultData passOrder(@RequestBody Orders orders){
        ordersService.passOrder(orders);
        return ResultData.success("shit");
    }
    @PostMapping("/equipmentConfirm")
    public ResultData equipmentConfirm(@RequestBody Orders orders){
        System.out.println(orders.getNote());
        ordersService.equipmentConfirm(orders);
        return ResultData.success("shit");
    }
    @PostMapping("/shipmentConfirm")
    public ResultData shipmentConfirm(@RequestBody Orders orders){
        ordersService.shipmentConfirm(orders);
        return ResultData.success("shit");
    }
}
